<script type="text/javascript">
function showConfirmDialogWithLink(msg,link){
    Ext.MessageBox.show({
        title:'Customer Conntect',
        msg:msg,
        buttons:Ext.Msg.YESNO,
        fn:function (btn) {

            if (btn == 'no') {
                return false;
            } else {
               window.location = link;
            }
        }
    })
        
}
function showCmNotice(){
	   Ext.MessageBox.show({
        title:'Customer Connect',
        msg:'You are not authorized to use this feature',
           buttons:Ext.Msg.YES
      
    })
	}
</script>
<div class="container" style="min-height: 206px;">   
    <div class="heading"><a id="sidebaropengear" onclick="showSideBarSettings();" href="javascript:void(0);"><img width=16" height="16" src="./images/gear.png" alt="" /></a>Information</div>
    <div id="selectedcustomernav" class="inside" style="padding-bottom:0px !important;">
        <input type="text" id="remote-users" style="width:143px !important;display:none"/>
        <div class="selectedcustomer" style="text-align:center;">
            <center><img src="<?=getImage($location->customer->image,'images/content/',75,75);?>"/></center>
            <span id="selectedcustomer"><a href="index.php?r=Customers/update&id=<?=$location->customer->custno?>"><?php echo $location->customer->lastname?></a></span>

        </div>


    </div>

    <div class="inside" style="padding-top:0px; padding-bottom:0px;">
        <h5 style="padding-left:11px;">Available Actions</h5>
        <ul class="links" style="margin-left:0px !important;">
            <li id='blankforvalidation2' style="display:none">&nbsp;</li>                        

            <?php if (isset($location) && $location->locno!=NULL): ?>
                
            
                <li><?php echo CHtml::link('Add Quote', array('invoices/create','custno'=>$location->custno,'locno'=>$location->locno,'type'=>Invoice::TYPE_QUOTE),array('class'=>'add-button'));?></li>
                <li><?php echo CHtml::link('Add Sales Order', array('invoices/create','custno'=>$location->custno,'locno'=>$location->locno,'type'=>Invoice::TYPE_SALES_ORDERS),array('class'=>'add-button'));?></li>
                <li><?php echo CHtml::link('Add Invoice', array('invoices/create','custno'=>$location->custno,'locno'=>$location->locno,'type'=>Invoice::TYPE_INVOICE),array('class'=>'add-button'));?></li>
				       <?php 
      $user = new Users();
     
   if($user->checkPermission('invoices/createCreditMemo',Yii::app()->user->id)):
    ?>
   <li><a onclick="showConfirmDialogWithLink(' Are you sure you want to create a credit memo?', '<?=  CHtml::normalizeUrl( array('invoices/create','custno'=>$location->custno,'locno'=>$location->locno,'type'=>Invoice::TYPE_CREDIT_MEMO))?>')" class="add-button">Add Credit Memo</a></li>
<? else:?>
  <li><a class="add-button" href="javascript:void(0)" 
           onclick="showCmNotice()">Create Credit Memo</a></li>
<?php endif; ?>
 
				 
            <?php endif ?>
        </ul>
    </div>

</div>
